package com.xxb.datasource.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxb.datasource.entity.OrderDetails;
import com.xxb.datasource.mapper.OrderDetailsMapper;
import com.xxb.datasource.service.IOrderDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author panghu
 * @version 1.0.0
 * @createTime 2023年07月09日 12:54:00
 * @Description
 */
@Service
@Slf4j
public class OrderDetailsServiceImpl extends ServiceImpl<OrderDetailsMapper, OrderDetails> implements IOrderDetailsService {

    @Resource
    private OrderDetailsMapper orderDetailsMapper;


    @Override
    @DS("slave_2")
    public boolean saveOrderDetails() {
        OrderDetails orderDetails = new OrderDetails();
        orderDetails.setOrderId(1011021);
        orderDetails.setSkuId(88888);
        orderDetails.setUserId(2002);
        orderDetails.setNum(5);
        orderDetails.setPrice(new BigDecimal(388.99));
        orderDetails.setActualPrice(new BigDecimal(256.69));
        int rs1 = orderDetailsMapper.insert(orderDetails);
        return rs1 > 0;
    }

}
